home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 6 / 006.d81 / pps #11 < prev    next >
Text File  |  2022-08-26  |  3KB  |  178 lines

  1.  PEEKs, POKEs, and SYSes -- Part 11
  2.  
  3.            by Jimmy Weiler
  4.  
  5.  
  6.  
  7. ======================================
  8. Location:51-52   Hexadecimal: $0033-34
  9. Official Label: FRETOP       Type: RAM
  10. Useful BASIC commands: PEEK, POKE
  11. ======================================
  12. Location 55-56   Hexadecimal: $0037-38
  13. Official Label: MEMSIZ       Type: RAM
  14. Useful BASIC commands: PEEK, POKE
  15. ======================================
  16.  
  17.  
  18.  
  19. MEMSIZ and FRETOP can be used to chop
  20.  
  21. the top off of BASIC RAM to make room
  22.  
  23. for your machine language code or
  24.  
  25. sprites.
  26.  
  27.  
  28.  
  29.   Let's start with a diagram to show
  30.  
  31. how these locations are used, then
  32.  
  33. I'll follow with an explanation.
  34.  
  35.  
  36.   This is a chart of the top of RAM
  37.  
  38. after your program has used three
  39.  
  40. string variables.
  41.  
  42.  
  43. 40960  ------------------   <---MEMSIZ
  44.        !the first string!
  45.        !used by your pro!  s
  46.        !gram is here....!   t
  47.        ------------------    r
  48. 40912  !the second strin!  v  i
  49.        !g is just below !   a  n
  50.        !the first string!    r  g
  51.        ------------------  s  i
  52. 40864  !and this is the !   t  a
  53.        !third and last s!    a  b
  54.        !tring your progr!     c  l
  55.        !am used.  Notice!      k  e
  56.        !that each subseq!
  57.        !uent string is p!
  58.        !laced just below!
  59.        !the previous one!
  60. 40736  ------------------   <---FRETOP
  61.  
  62.  
  63.  
  64.  
  65.   MEMSIZE points to the highest RAM
  66.  
  67. memory location available to your
  68.  
  69. program for variable storage.
  70.  
  71. Normally PEEK(55)+PEEK(56)*256 will
  72.  
  73. equal 40960, so normally string
  74.  
  75. variables will be stored downward from
  76.  
  77. that address.
  78.  
  79.  
  80.  
  81.   FRETOP points to the TOP of the FREE
  82.  
  83. RAM (RAM that doesn't have any
  84.  
  85. variables stored in it yet).  Every
  86.  
  87. time another string variable is tacked
  88.  
  89. onto the bottom of the string variable
  90.  
  91. stack, FRETOP drops to the bottom of
  92.  
  93. that latest variable.  That happens
  94.  
  95. every time you assign any string.
  96.  
  97. [LET A$=B$:C$=MID$(B$,4):M$=CHR$(13)]
  98.  
  99.  
  100.   So what good is all this?  For
  101.  
  102. normal, healthy people, no good at
  103.  
  104. all.  But for us hackers, it's the
  105.  
  106. answer to our question, 'Where can I
  107.  
  108. put my binary stuff where my BASIC
  109.  
  110. program won't trounce it?'
  111.  
  112.  
  113.   If you've discovered the available
  114.  
  115. RAM at location 49152, you've probably
  116.  
  117. already filled it with machine code
  118.  
  119. several times over.  You've probably
  120.  
  121. even put code in the cassette buffer
  122.  
  123. at 828 to 1023.
  124.  
  125.  
  126.  
  127.   If you put your binary stuff low in
  128.  
  129. memory (near 2049), then your BASIC
  130.  
  131. program will load right on top of it
  132.  
  133. (unless you know how to mess with
  134.  
  135. TXTTAB [43-44] -- but that's another
  136.  
  137. peeks, pokes, & sys article).
  138.  
  139.  
  140.  
  141.   If you put your binary stuff
  142.  
  143. somewhere in the middle of BASIC RAM,
  144.  
  145. there's a CHANCE nothing will get
  146.  
  147. stored into it, but why take chances?
  148.  
  149.  
  150.  
  151.   That leaves..... the top of BASIC
  152.  
  153. RAM.  To use that space you need to
  154.  
  155. know how to move FRETOP and MEMSIZ up
  156.  
  157. and down at will.
  158.  
  159.  
  160.  
  161.   This example moves FRETOP and
  162.  
  163. MEMSIZ down to address 24576.  You can
  164.  
  165. use ANY RAM address from 2051 to
  166.  
  167. 40960.  Just remember that if you
  168.  
  169. don't leave enough room between 2049
  170.  
  171. and MEMSIZ for your program AND its
  172.  
  173. variables you will get an OUT OF
  174.  
  175. MEMORY error.
  176.  
  177. ======== continued in Part 12 ========
  178.